StockCbExercises.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use client';
  2. import '@/app/styles/data-table.scss';
  3. import DataTable, { DataTableColumn } from '@/components/table/DataTable';
  4. import { CbExerciseRow } from '@/types/seibro';
  5. import { formatDecimal, formatShares, dateOrDash } from '@/lib/utils/market';
  6. function buildColumns(): DataTableColumn<CbExerciseRow>[] {
  7. return [
  8. {
  9. key: 'rgtStdDt',
  10. header: '행사일',
  11. align: 'left',
  12. priority: 'high',
  13. cell: (row) => row.rgtStdDt
  14. },
  15. {
  16. key: 'bond',
  17. header: '채권',
  18. align: 'left',
  19. priority: 'high',
  20. cellClassName: 'data-table__cell--name',
  21. cell: (row) => (
  22. <span className='stock-cell'>
  23. <span className='stock-cell__name'>{row.bondName ?? row.bondIsin}</span>
  24. {row.bondKind && <span className='market__cls-badge'>{row.bondKind}</span>}
  25. </span>
  26. )
  27. },
  28. {
  29. key: 'exercisePrice',
  30. header: '행사가',
  31. align: 'right',
  32. priority: 'high',
  33. cell: (row) => (row.exercisePrice === null ? '—' : `${formatDecimal(row.exercisePrice, 0)}원`)
  34. },
  35. {
  36. key: 'exerciseQty',
  37. header: '행사주수',
  38. align: 'right',
  39. priority: 'high',
  40. cell: (row) => (row.exerciseQty === null ? '—' : formatShares(Math.round(row.exerciseQty)))
  41. },
  42. {
  43. key: 'listDt',
  44. header: '상장일',
  45. align: 'center',
  46. priority: 'low',
  47. cell: (row) => dateOrDash(row.listDt)
  48. }
  49. ];
  50. }
  51. export default function StockCbExercises({ rows }: { rows: CbExerciseRow[] })
  52. {
  53. return (
  54. <DataTable<CbExerciseRow>
  55. caption='CB/BW 행사 내역 — 행사일, 채권, 행사가, 행사주수, 상장일'
  56. columns={buildColumns()}
  57. rows={rows}
  58. rowKey={(row, index) => `${row.bondIsin}-${row.rgtStdDt}-${index}`}
  59. emptyMessage='수집된 CB/BW 행사 내역이 없습니다.'
  60. />
  61. );
  62. }